﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ZP.Web.Admin.Company.Default" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <script type="text/javascript" src="../Kwan.Base.js"></script>
    <script type="text/javascript" src="Kwan.Company.js"></script>
    <form id="Form2" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Gray" DirectMethodNamespace="Company" />

        <ext:Store runat="server" ID="IndtypeDS">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="Code" />
                        <ext:RecordField Name="Name" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <SortInfo Field="Code" Direction="ASC" />
        </ext:Store>

        <ext:Store ID="Store1" runat="server" OnRefreshData="RefreshDS" RemoteSort="True">
            <Proxy>
                <ext:PageProxy />
            </Proxy>
            <Reader>
                <ext:JsonReader IDProperty="EntityID">
                    <Fields>
                        <ext:RecordField Name="EntityID" />
						<ext:RecordField Name="Address" />
						<ext:RecordField Name="CompanyName" />
						<ext:RecordField Name="ContactPerson" />
						<ext:RecordField Name="CreatedDate" />
						<ext:RecordField Name="Email" />
						<ext:RecordField Name="Employees" />
						<ext:RecordField Name="IndustryCode" />
                        <ext:RecordField Name="IndustryName" />
						<%--<ext:RecordField Name="Memo" />--%>
						<ext:RecordField Name="ModifiedDate" />
                        <ext:RecordField Name="Modifier" />
						<ext:RecordField Name="Scale" />
						<ext:RecordField Name="Setup" />
						<ext:RecordField Name="Type" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                <ext:Parameter Name="limit" Value="20" Mode="Raw"/>
            </AutoLoadParams>
            <SortInfo Field="EntityID" Direction="DESC" />
            <Listeners> 
                <LoadException Handler="Ext.MessageBox.alert('系统提示', response.statusText);" />                            
            </Listeners>
        </ext:Store>
        <ext:Viewport runat="server" Layout="Fit">
            <Items>
        <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" AutoExpandColumn="CompanyName" Header="False" Frame="true" Height="500">
            <ColumnModel runat="server">
			    <Columns>
                    <ext:RowNumbererColumn />
					<ext:Column Header="名称" DataIndex="CompanyName" />
					<ext:Column Header="行业" DataIndex="IndustryName" Width="120" />
					<ext:Column Header="联系人" DataIndex="ContactPerson" Width="80" />
					<ext:Column Header="邮箱" DataIndex="Email" Width="80" />
					<ext:Column Header="职工人数" DataIndex="Employees" Width="80">
                        <Renderer Fn="Kwan.ChangeEmployees" />
                    </ext:Column>
					<ext:Column Header="类型" DataIndex="Type" Width="80">
                        <Renderer Fn="Kwan.ChangeComType" />
                    </ext:Column>
					<ext:DateColumn Header="创建日期" DataIndex="CreatedDate" Width="80" />
                    <ext:CommandColumn Header="显示" DataIndex="Scale" Width="40">
                        <Commands>
                            <ext:GridCommand CommandName="Scale" />
                        </Commands>
                        <PrepareToolbar Fn="Kwan.prepareInt" />
                    </ext:CommandColumn>
                    <ext:CommandColumn Width="55" Hideable="false">
                        <Commands>
                            <ext:GridCommand CommandName="Delete" Icon="Delete" Text="删除">
                                <ToolTip Text="删除该条记录" />
                            </ext:GridCommand>
                        </Commands>
                    </ext:CommandColumn>
			    </Columns>
            </ColumnModel>
            <TopBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:ComboBox ID="searchIndtype" runat="server" Width="300" FieldLabel="行业" LabelWidth="35" LabelAlign="Right" Editable="false" StoreID="IndtypeDS" DisplayField="Name" ValueField="Code" EmptyText="请选择..." ItemSelector="td.list-item">
                            <Template ID="Template1" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <tpl if="[xindex] == 1"><table class="txtCustomers-list"></tpl>
                                        <tpl if="[xindex - 1] % 2 == 0"><tr></tpl>
                                        <td class="list-item" align="center" width="50%" style="padding:3px;height:35px;">{Name}</td>
                                        <tpl if="[xcount-xindex]==0"></tr></table></tpl>
                                    </tpl>
                                </Html>
                            </Template>
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                            </Triggers>
                            <Listeners>
                                <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                <TriggerClick Handler="if(index == 0) { this.focus().clearValue(); trigger.hide(); #{txtFilter}.setValue(''); }" />
                                <Select Handler="Store1.reload();" />
                            </Listeners>
                        </ext:ComboBox>
                        <ext:ToolbarSeparator />
                        <ext:TriggerField ID="txtSearch" runat="server" EmptyText=" 搜索企业.." EnableKeyEvents="true">
                            <Listeners>
                                <KeyDown Handler="if(!Ext.isEmpty(this.getValue())) { this.triggers[0].show();}else{this.triggers[0].hide();}" />
                                <TriggerClick Handler="if (index == 1) { Store1.reload(); } if(index == 0) { #{txtSearch}.reset(); this.triggers[0].hide(); }" />
                            </Listeners>
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" HideTrigger="true" Qtip="清空" />
                                <ext:FieldTrigger Icon="Search" Qtip="搜索"/>
                            </Triggers>
                        </ext:TriggerField>
                        <ext:ToolbarFill />
                        <ext:Button ID="BtnAddInfo" runat="server" Text="添加" Icon="Add">
                            <DirectEvents>
                                <Click OnEvent="BtnAddInfo_Click" />
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button ID="BtnDeleteInfo" runat="server" Text="批量删除" Icon="Delete">
                            <Listeners>
                                <Click Handler="Kwan.CheckDelete(#{GridPanel1}.getRowsValues({selectedOnly:true}));" />
                            </Listeners>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="BtnChangeScale" runat="server" Text="更改级别" Icon="ArrowSwitchBlueGreen">
                            <Menu>
                                <ext:Menu ID="Menu1" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="Scale_0" runat="server" Text="禁用" Icon="Decline" />
                                        <ext:MenuItem ID="Scale_1" runat="server" Text="免费" Icon="BulletTick" />
                                        <ext:MenuItem ID="Scale_2" runat="server" Text="VIP" Icon="Ruby" />
                                    </Items>
                                    <Listeners>
                                        <%--<ItemClick Handler="Company.ChangeState(Kwan.GetIDs(#{GridPanel1}.getRowsValues({selectedOnly:true})),menuItem.id);" />--%>
                                        <ItemClick Handler="Kwan.jsonServicce(['ChangeSelected',Kwan.GetIDs(#{GridPanel1}.getRowsValues({selectedOnly:true})),menuItem.id])" />
                                    </Listeners>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:ComboBox ID="CmbIndtype" runat="server" Width="150" FieldLabel="行业" LabelWidth="35" LabelAlign="Right" Editable="false" StoreID="IndtypeDS" DisplayField="Name" ValueField="Code" EmptyText="更改行业..." ItemSelector="td.list-item">
                        <Template ID="Template2" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <tpl if="[xindex] == 1"><table class="txtCustomers-list"></tpl>
                                        <tpl if="[xindex - 1] % 1 == 0"><tr></tpl>
                                        <td class="list-item" align="center" width="50%" style="padding:3px;height:35px;">{Name}</td>
                                        <tpl if="[xcount-xindex]==0"></tr></table></tpl>
                                    </tpl>
                                </Html>
                            </Template>
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                            </Triggers>
                            <Listeners>
                                <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                <TriggerClick Handler="if(index == 0) { this.focus().clearValue(); trigger.hide(); #{txtFilter}.setValue(''); }" />
                                <Select Handler="Company.ChangeState(Kwan.GetIDs(#{GridPanel1}.getRowsValues({selectedOnly:true})),'IndustryCode_'+this.getValue());" />
                            </Listeners>
                        </ext:ComboBox>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <SelectionModel>
               <ext:CheckboxSelectionModel runat="server" />                   
            </SelectionModel>
            <LoadMask ShowMask="true" />
            <SaveMask ShowMask="true" />
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="20">
                    <Items>
                        <ext:Label runat="server" Text="每页显示:" />
                        <ext:ToolbarSpacer runat="server" Width="10" />
                        <ext:ComboBox Editable="false" runat="server" Width="80">
                            <Items>
                                <ext:ListItem Text="10" />
                                <ext:ListItem Text="20" />
                                <ext:ListItem Text="50" />
                                <ext:ListItem Text="100" />
                            </Items>
                            <SelectedItem Value="20" />
                            <Listeners>
                                <Select Handler="#{PagingToolBar1}.pageSize = parseInt(this.getValue()); #{PagingToolBar1}.doLoad();" />
                            </Listeners>
                        </ext:ComboBox>
                    </Items>
                </ext:PagingToolbar>
            </BottomBar>
            <Listeners>
                <Command Handler="Kwan.CellCommand(this, record, command, rowIndex)" />
                <RowDblClick Handler="Kwan.CellCommand(this, this.store.getAt(rowIndex), 'Edit', rowIndex)" />
            </Listeners>        
        </ext:GridPanel>
        </Items>
        </ext:Viewport>
        <ext:Window ID="EditWindow" runat="server" Icon="Group" Title="编辑数据" Width="650" Height="500" AutoShow="false" Modal="true" Collapsible="true" Maximizable="true" Hidden="true" Layout="Fit" LabelWidth="70">
            <Items>
                <ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Border="false" DeferredRender="false">
                    <Items>
                        <ext:FormPanel ID="EditForm" MonitorValid="true" runat="server" Title="基本信息" Icon="ChartOrganisation" Padding="5" Layout="Form" LabelAlign="Right" LabelWidth="70" MonitorResize="true">
                            <Items>
                                <ext:Hidden ID="txtID" runat="server" />
								<ext:TextField ID="txtCompanyName" FieldLabel="名称" AnchorHorizontal="98%" runat="server" />
                                <ext:ComboBox ID="txtIndtype" Editable="false" StoreID="IndtypeDS" FieldLabel="职能类别" DisplayField="Name" ValueField="Code" EmptyText="请选择..." AnchorHorizontal="50%" AllowBlank="false" ItemSelector="td.list-item" runat="server">
                                    <Template ID="Template3" runat="server">
                                        <Html>
                                            <tpl for=".">
                                                <tpl if="[xindex] == 1"><table class="txtCustomers-list"></tpl>
                                                <tpl if="[xindex - 1] % 2 == 0"><tr></tpl>
                                                <td class="list-item" align="center" width="20%" style="padding:3px;height:30px;">{Name}</td>
                                                <tpl if="[xcount-xindex]==0"></tr></table></tpl>
                                            </tpl>
                                        </Html>
                                    </Template>
                                </ext:ComboBox>
								<ext:TextField ID="txtAddress" FieldLabel="地址" AnchorHorizontal="98%" runat="server" />
								<ext:TextField ID="txtContactPerson" FieldLabel="联系人" AnchorHorizontal="98%" runat="server" />
								<ext:DateField ID="txtCreatedDate" FieldLabel="创建日期" AnchorHorizontal="30%" runat="server" />
								<ext:TextField ID="txtEmail" FieldLabel="邮箱" AnchorHorizontal="98%" runat="server" />
								<ext:TextField ID="txtEmployees" FieldLabel="职工人数" AnchorHorizontal="98%" runat="server" />
								<ext:ComboBox ID="txtType" FieldLabel="类型" EmptyText="请选择" Editable="false" AnchorHorizontal="30%" runat="server">
                                    <Items>
                                        <ext:ListItem Value="1" Text="民营企业" />
                                        <ext:ListItem Value="2" Text="股份制企业" />
                                        <ext:ListItem Value="3" Text="行政机关" />
                                        <ext:ListItem Value="4" Text="社会团体" />
                                        <ext:ListItem Value="5" Text="事业单位" />
                                        <ext:ListItem Value="6" Text="国有企业" />
                                        <ext:ListItem Value="7" Text="外资企业" />
                                        <ext:ListItem Value="8" Text="跨国集团" />
                                        <ext:ListItem Value="0" Text="其他" />
                                    </Items>
                                </ext:ComboBox>


                                <ext:CheckboxGroup ID="CheckboxGroup1" runat="server" ColumnsNumber="2" FieldLabel="选项" AnchorHorizontal="50%">
                                    <Items>
                                        <ext:Checkbox ID="txtScale" BoxLabel="显示" runat="server" />
                                    </Items>
                                </ext:CheckboxGroup> 
								<ext:HtmlEditor ID="txtMemo" runat="server" Height="130" AnchorHorizontal="98%" />
                            </Items>
                            <Listeners>
                                <ClientValidation Handler="#{SaveButton}.setDisabled(!valid);" />
                            </Listeners>
                        </ext:FormPanel>
                    </Items>
                </ext:TabPanel>
            </Items>
            <Buttons>
                <ext:Button ID="SaveButton" runat="server" Text="保存" Icon="Disk">
                    <DirectEvents>
                        <Click OnEvent="SaveEditWindow" Failure="Ext.MessageBox.alert('系统提示', response.statusText);">
                            <EventMask Target="CustomTarget" CustomTarget="={#{EditWindow}.body}" ShowMask="True" />
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="CancelButton" runat="server" Text="返回" Icon="Cancel">
                    <Listeners>
                        <Click Handler="#{EditWindow}.hide(null);" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Window>
    </form>
</body>
</html>